<%@ page import="id.co.gomobile.assessment.User" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>List of Users</title>
    </head>
    <body>
    <g:render template="/shared/navigation" />
    
    <div id="body">
    
    <h1>List of Users</h1>
    
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    
    <div class="list">
    <table>
        <col width="50" />
        <col />
        <col width="200" />
        <col width="100" />
        <col width="100" />
        <col width="150" />
        <thead>
            <tr>
                <th colspan="6" align="right">${userInstanceList.size()} of ${userInstanceTotal} displayed</th>
            </tr>
            <tr>
                <g:sortableColumn property="id" title="${message(code: 'user.id.label', default: 'Id')}" />
                <g:sortableColumn property="username" title="${message(code: 'user.username.label', default: 'Username')}" />
                <g:sortableColumn property="email" title="${message(code: 'user.email.label', default: 'Email')}" />
                <g:sortableColumn property="enabled" title="${message(code: 'user.enabled.label', default: 'Enabled')}" />
                <th title="Administrator">Administrator</th>
                <th title="Action">Action</th>
            </tr>
        </thead>
        <tbody>
        <g:each in="${userInstanceList}" status="i" var="userInstance">
            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <td>${fieldValue(bean: userInstance, field: "id")}</td>
                <td>${fieldValue(bean: userInstance, field: "username")}</td>
                <td>${fieldValue(bean: userInstance, field: "email")}</td>
                <td><g:formatBoolean boolean="${userInstance?.enabled}" true="Yes" false="No" /></td>
                <td><g:formatBoolean boolean="${userInstance?.isAdministrator()}" true="Yes" false="No" /></td>
                <td style="text-align: center">
                    <g:form action="show" id="${userInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_table.png')}" alt="Show Test" />
                    </g:form>
                    &nbsp;
                    <g:form action="edit" id="${userInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_edit.png')}" alt="Edit Test" />
                    </g:form>
                    &nbsp;
                    <g:form action="delete" id="${userInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_delete.png')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" alt="Delete Question" />
                    </g:form>
                </td>
            </tr>
        </g:each>
        </tbody>
    </table>
    </div>
    <div class="paginateButtons">
        <g:paginate total="${userInstanceTotal}" />
    </div>
    
    <br/>
    
    <div class="buttons">
        <g:form>
            <span class="button"><g:actionSubmit class="create" action="create" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
        </g:form>
    </div>
    
    </div>
    </body>
</html>